﻿@using NewLife.Common;
@using XCode.Membership;
@{
    var user = ViewBag.User as IUser ?? User.Identity as IUser;
    var uid = 0;
    var roleNames = "";
    if (user != null)
    {
        uid = user.ID;
        roleNames = user.Roles == null ? "" : user.Roles.Join();
    }
    var cfg = ViewBag.Config as SysConfig;
    var name = cfg == null ? "" : cfg.DisplayName;
}
<!-- #section:basics/navbar.layout -->
<div id="navbar" class="navbar navbar-default">
    <script type="text/javascript">
        try { ace.settings.check('navbar', 'fixed') } catch (e) { }
    </script>

    <div class="navbar-container" id="navbar-container">
        <!-- #section:basics/sidebar.mobile.toggle -->
        <button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler" data-target="#sidebar">
            <span class="sr-only">Toggle sidebar</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <!-- /section:basics/sidebar.mobile.toggle -->
        <div class="pull-left">
            <!-- #section:basics/navbar.layout.brand -->
            <a href="@ViewBag.Main" class="navbar-brand" target="main">
                <small>
                    @name
                </small>
            </a>
        </div>

        <!-- #section:basics/navbar.dropdown -->
        <div class="navbar-buttons navbar-header pull-right" role="navigation">
            <ul class="nav ace-nav">
                <!-- #section:basics/navbar.user_menu -->
                <li class="light-blue">
                    <a data-toggle="dropdown" href="~/Admin/User/Info/@uid" class="dropdown-toggle" target="main">
                        @if (user != null && !user.Avatar.IsNullOrEmpty())
                        {
                            <img class="nav-user-photo" src="@user.GetAvatarUrl()" alt="@user" />
                        }
                        <span class="user-info">
                            @*<small>欢迎，</small>*@
                            @user <br /> [@roleNames]
                        </span>

                        <i class="ace-icon fa fa-caret-down"></i>
                    </a>

                    <ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                        <li>
                            <a href="~/" target="_blank">
                                <i class="ace-icon fa fa-cog"></i>
                                网站首页
                            </a>
                        </li>

                        @*@if (user.Has("Admin/Sys", PermissionFlags.Detail))
                            {
                                <li>
                                    <a href="~/Admin/Sys" target="main">
                                        <i class="ace-icon fa fa-cog"></i>
                                        设置
                                    </a>
                                </li>
                            }*@

                        <li>
                            <a href="~/Admin/User/Info/@uid" target="main">
                                <i class="ace-icon fa fa-user"></i>
                                个人信息
                            </a>
                        </li>

                        <li class="divider"></li>

                        <li>
                            <a href="~/Admin/User/Logout">
                                <i class="ace-icon fa fa-power-off"></i>
                                注销
                            </a>
                        </li>
                    </ul>
                </li>

                <!-- /section:basics/navbar.user_menu -->
            </ul>
        </div>

        <!-- /section:basics/navbar.dropdown -->
    </div>
    <!-- /.navbar-container -->
</div>
<!-- /section:basics/navbar.layout -->